const gis = this.getApiPage().getApiWidgetByAliasName('三维组件');
const prefix = this.pageObj.getVariables().find(v => v.name === "environmentType")?.value;
const { dataSource } = this.widgetObj._option;
console.log('变更', $event)
const { dataIndex, formValue } = $event;
function basicsGet(url) {
    const headers = { "Content-type": "application/json" }
    return fetch(`/${prefix}Basics/basics-main/system/${url}`, { headers }).then(res => res.json())
}
if (dataIndex === 'areaId') {
    dataSource.occurrencePlace = formValue.title;
    this.widgetObj._option.dataSource = dataSource;
    this.widgetObj.setFormData('form_19', {
        occurrencePlace: formValue.title
    });
    basicsGet(`position/list?projectAreaCode=${formValue.id}`, 'GET',).then(res => {
        if(res.resultCode === '000000') {
            const arr = res.result.rows.map(v => ({...v, name: v.pointName, value: v.id}))
            this.widgetObj.asyncSelectOptions('eventPoint', arr)
        }
    })
    basicsGet(`equipmentObject/listDetailByEquipmentCode?equipmentTypeCode=camera&areaId=${formValue.id}`).then(res => {
        if (res?.resultCode === '000000') {
            res.result.rows.forEach(i=>{
                i.name = i.equipmentName;
                i.value = i.equipmentCode;
            })
            this.widgetObj.asyncSelectOptions('sourceDeviceId', res.result.rows)
            this.widgetObj.tempData = res.result.rows
        }
    })

    if(formValue.parentProjectAreaId == -1) {
        gis.widgetObj.gisMap.setSence(formValue.projectAreaName);
    }else if (formValue.projectAreaRange) {
        gis.widgetObj.gisMap.areaPosition(formValue.id);
    } else {
        layer?.msg('未设置地图坐标！')
    }
}else if(dataIndex === 'eventPoint') {
    this.widgetObj.setFormData('form_19', {
        pointId: formValue.id,
        xCoordinate: formValue.xCoordinate,
        yCoordinate: formValue.yCoordinate,
        zCoordinate: formValue.zCoordinate,
    });
}




console.log('表单项变更: => ', $event)